

//
//  SixthCell.m
//  房源、商铺、写字楼详情页
//
//  Created by MB__Lee on 2018/5/23.
//  Copyright © 2018年 MB__Lee. All rights reserved.
//

#import "SixthCell.h"

#import "SixCoCell.h"
#import "CreatModelMutTool.h"

#define Item_width MBScale(60)
#define Item_hight MBScale(60)




@interface SixthCell()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
@property (weak, nonatomic) IBOutlet UILabel *sheShiLabel;

@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;


//collectionview 的数据源
@property(nonatomic,strong)NSMutableArray *collectionViewcCellMut;


@end

static NSString *SixCoCell_Identi = @"SixCoCell";
@implementation SixthCell
-(NSMutableArray *)collectionViewcCellMut{
    if (!_collectionViewcCellMut) {
        _collectionViewcCellMut = [NSMutableArray array];
    }
    return  _collectionViewcCellMut;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    [self.collectionView registerNib:[UINib nibWithNibName:SixCoCell_Identi bundle:nil] forCellWithReuseIdentifier:SixCoCell_Identi];
    self.collectionView.allowsSelection = NO;
    
    self.collectionView.scrollEnabled = NO;

    

    
    
}

-(void)setModel:(MBFangDetailModel *)model{
   [super setModel:model];
    
    [self.collectionViewcCellMut removeAllObjects];
    //collectionview 的数据源
    [self.collectionViewcCellMut addObjectsFromArray:[CreatModelMutTool creatModelToolCreatWithArray:model.subsidiary]];
    [self.collectionView reloadData];
    
    
    //根据Category 来隐藏显示  配套设置
    if ([model.category isEqualToString:@"1001"]) {
        self.sheShiLabel.text = @"  配套设施";
    }else{
        self.sheShiLabel.text = @" ";
    }
    
    
}
#pragma mark --collectionveiwdelegate
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return  self.collectionViewcCellMut.count;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    SixCoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:SixCoCell_Identi forIndexPath:indexPath];
//    cell.
    cell.coModel = self.collectionViewcCellMut[indexPath.row];
    
    return  cell;
}

#pragma mark --- 大小设置
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    return  CGSizeMake(Item_width, Item_hight);
}
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
    return  MBScale(10);
}
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
    return  MBScale(10);
}
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    return  UIEdgeInsetsMake(0, MBScale(15), MBScale(15), MBScale(10));
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
